'use strict'
const path = require('path')

function resolve(dir) {
  return path.join(__dirname, dir)
}

// If your port is set to 80,
// use administrator privileges to execute the command line.
// For example, Mac: sudo npm run

// All configuration item explanations can be find in https://cli.vuejs.org/config/
module.exports = {
  publicPath: process.env.NODE_ENV === 'production' ? './' : '/H5/',
  outputDir: `dist/cockpit/`,
  assetsDir: 'static',
  lintOnSave: true,
  productionSourceMap: false,

  css: {
    loaderOptions: {
      postcss: {
        plugins: [
          require('postcss-px2rem')({
            remUnit: 37.5,
            remPrecision: 2 // rem的小数点后位数
          })
        ]
      }
    }
  },

  devServer: {
    publicPath: '/H5/',
    port: '8080',
    open: true,
    disableHostCheck: true,
    overlay: {
      warnings: false,
      errors: true
    },
    proxy: {
      '/cockpit/app': {
        // target: 'http://192.168.77.224:8558/',
        target: 'https://muac.quanyou.com.cn/cockpit/',
        // target: 'http://172.19.4.220:8558/', // gaoxinhai
        // changeOrigin: true,
        pathRewrite: {
          '^/cockpit/app': '/app'
        }
      }
    }
  },

  configureWebpack: {
    // provide the app's title in webpack's name field, so that
    // it can be accessed in index.html to inject the correct title.
    name: 'wx-verifyscan',
    resolve: {
      alias: {
        '@': resolve('src')
      }
    }
  },

  pluginOptions: {
    'style-resources-loader': {
      preProcessor: 'less',
      patterns: [path.resolve(__dirname, './src/styles/index.less')]
    }
  }
}
